package com.usian.controller;

import com.usian.api.user.ApUserRealnameControllerApi;
import com.usian.common.constants.AdminConstants;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.user.dtos.AuthDto;
import com.usian.service.ApUserRealnameService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController implements ApUserRealnameControllerApi {
    @Autowired
    private ApUserRealnameService apUserRealnameService;


    @Override
    @PostMapping("list")
    @ApiOperation("用户")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.list(dto);
    }

    @Override
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {
         dto.setStatus(AdminConstants.PASS_AUTH);
         return apUserRealnameService.updateStatusById(dto);
    }


    @PostMapping("/authFail")
    @Override
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        dto.setStatus(AdminConstants.FAIL_AUTH);
        return apUserRealnameService.updateStatusById(dto);
    }
}
